from ncclient import manager

ip = '203.0.113.1'
netconf_port = '830'
netconf_user = 'qytang'
netconf_password = 'Dashu666!'

with manager.connect(host=ip, port=netconf_port,
                     username=netconf_user,
                     password=netconf_password,
                     hostkey_verify=False,
                     device_params={'name':'csr'},
                     allow_agent = False,
                     look_for_keys = False) as m:

    # c = m.get_config(source='running').data_xml
    # print(c)
    # with open("d:\michael\Videos\{}.xml".format(ip), 'w') as f:
    #     f.write(c)
    for capability in m.server_capabilities:
        print(capability)
        # with open('/home/qyt/Documents/capabillity.txt', mode='a+') as capability_file:
        #     capability_file.write(capability)
        #     capability_file.write('\n')

